package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.vo.OrderStatusBean;
import com.cskaoyan.bean.vo.WxUserOrderIndex;
import com.cskaoyan.service.wx.WxUserService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.controller.wx
 * @date 2020/12/9 10:39
 * @Copyright © 暂时还没有
 * @description
 */
@Controller
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    WxUserService wxUserService;

    @ResponseBody
    @RequestMapping("index")
    public BaseRespVo userIndex(HttpSession session){
//        Integer userId = (Integer) session.getAttribute("id");
        //从session中获取id，查询order表格
        Integer userId = (Integer)SecurityUtils.getSubject().getSession().getAttribute("id");
        WxUserOrderIndex orderIbdex = wxUserService.queryUserOrderIndex(userId);
       // List<WxUserOrderIndex> orderIndex = wxUserService.queryUserOrderIndex(1);

        OrderStatusBean order = new OrderStatusBean();
        order.setOrder(orderIbdex);

        return BaseRespVo.ok(order);
    }
}
